package com.drg.center.controller;

import com.drg.center.entity.param.*;
import com.drg.center.entity.result.SysUserExtVO;
import com.drg.center.entity.result.SysUserListVO;
import com.drg.center.entity.result.SysUserVO;
import com.guaike.core.entity.result.PageEntity;
import com.guaike.core.entity.result.Result;
import com.drg.center.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author: zhangxilin
 * @Date: 2024/5/23
 */
@RestController
@RequestMapping("/sys/user")
@Api(tags = "系统-系统用户接口组")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @PostMapping("/add")
    @ApiOperation(value = "添加")
    public Result<Boolean> add(@Valid @RequestBody SysUserAddDTO param){
        return sysUserService.add(param);
    }

    @PostMapping("/edit")
    @ApiOperation(value = "编辑")
    public Result<Boolean> edit(@Valid @RequestBody SysUserEditDTO param){
        return sysUserService.edit(param);
    }

    @GetMapping("/findPage")
    @ApiOperation(value = "列表")
    public Result<PageEntity<SysUserListVO>> page(@Valid SysUserListDTO param){
        return sysUserService.page(param);
    }

    @GetMapping("/findById")
    @ApiOperation(value = "基本信息")
    public Result<SysUserVO> findById(@ApiParam("ID") @RequestParam("id") Long id){
        return sysUserService.findById(id);
    }

    @GetMapping("/detail")
    @ApiOperation(value = "详情")
    public Result<SysUserExtVO> detail(@ApiParam("ID") @RequestParam("id") Long id){
        return sysUserService.detail(id);
    }

    @PostMapping("/editStatus")
    @ApiOperation(value = "启用、冻结")
    public Result<Boolean> editStatus(@Valid @RequestBody SysUserStatusDTO param){
        return sysUserService.editStatus(param);
    }

    @PostMapping("/resetPwd")
    @ApiOperation(value = "重置密码")
    public Result<Boolean> resetPwd(@Valid @RequestBody SysUserPwdResetDTO param){
        return sysUserService.resetPwd(param);
    }

}
